﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSharp.Core.Authorization.Resources;

namespace TSharp.Core.Authorization
{
    /// <summary>
    /// 授权判断
    /// </summary>
    public interface IAuthorityJudger
    {
        /// <summary> 
        /// 判断给定的用户对给指定的资源和操作是否有操作权限。
        /// </summary>
        bool CanAct(Guid actorId, Guid resourceKey, int operationId);
        /// <summary>
        /// 判断给定的用户对指定的资源和操作是否有权限【不包括继承权限】
        /// </summary>
        /// <param name="actorId">The actor id.</param>
        /// <param name="resourceKey">The resource key.</param>
        /// <param name="operationId">The operation id.</param>
        /// <returns><c>true</c> if this instance [can act no inherited] the specified actor id; otherwise, <c>false</c>.</returns>
        bool CanActWithoutInherited(Guid actorId, Guid resourceKey, int operationId);
        /// <summary> 
        /// 根据给出的条件，判断指定的参与者是否有权将对指定的资源的指定操作授予其他参与者
        /// </summary>
        bool CanAdmin(Guid actorId, Guid resourceKey, int operationId);

        /// <summary> 
        /// 获得指定参与者对资源拥有指定操作权限的所有资源
        /// </summary>
        List<Guid> GetCanActResourceKeys(Guid actorId, int operationId);

        /// <summary> 
        /// 获得指定参与者对资源拥有指定操作权限的所有资源
        /// </summary>
        List<Guid> GetCanActResourceKeys(Guid actorId, int operationId, DateTime versionDate);

        /// <summary> 
        /// 计算用户对资源的所有操作控制
        /// </summary>
        string JudgeCanActControlData(Guid actorId, Guid resourceKey, int maxOperationId);

        /// <summary> 
        /// 计算用户对资源继承得来的的所有操作控制
        /// </summary>
        string JudgeInheritedControlData(Guid actorId, Guid resourceKey, int maxOperationId);

        /// <summary> 
        /// 计算用户对资源的所有（授权）操作控制
        /// </summary>
        string JudgeCanAdminControlData(Guid actorId, Guid resourceKey, int maxOperationId);
    }
}
